package entity;

import java.io.IOException;

import settings.*;

import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;

import org.xml.sax.SAXException;

import settings.IdManager;

//@author A0105110J
@XmlRootElement
public class Source extends XMLentity {
	
	private final String rootKey = "source";
	private String id;
	private String name;
	
	public Source()
	{
		this.setId("NULL");
		this.setName("NULL");
	}
	
	public Source(String _name) throws TransformerConfigurationException, InstantiationException, IllegalAccessException, JAXBException, ParserConfigurationException, SAXException, IOException, TransformerException
	{
		this.setId(IdManager.getInstance().getLastId(rootKey));
		IdManager.getInstance().updateLastId(rootKey);
		this.setName(_name);
	}
	
	public String getId() {
		return id;
	}
	@XmlAttribute
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	
	@XmlAttribute
	public void setName(String name) {
		this.name = name;
	}
	
	public String toString()
	{
		return (id + ", " + name);
	}
}
